package com.corpgovernment.job.controller.vo.job;

import cn.hutool.core.date.DateUtil;
import com.corpgovernment.job.batchimport.entity.db.BatchImportRecordDo;
import com.corpgovernment.job.batchimport.enums.BatchImportStatusEnum;
import com.corpgovernment.job.batchimport.enums.BatchImportTypeEnum;
import lombok.Data;

import java.util.List;

/**
 * @author ldma
 * @date 2024/1/12
 */
@Data
public class PageBatchImportJobRecordRespVo {

    private Integer recordCount = 0;
    private List<BatchImportJobRecord> batchImportJobRecordList;

    @Data
    public static class BatchImportJobRecord {
        private Long id;
        private String typeName;
        private String orgId;
        private String uid;
        private String fileName;
        private String originalFile;
        private String processedFile;
        private Integer lineCount;
        private Integer successCount;
        private Integer errorCount;
        private String statusName;
        private String operationTime;

        public BatchImportJobRecord(BatchImportRecordDo batchImportRecordDo) {
            this.typeName = BatchImportTypeEnum.JOB.getName();
            this.id = batchImportRecordDo.getId();
            this.orgId = batchImportRecordDo.getOrgId();
            this.uid = batchImportRecordDo.getUid();
            this.fileName = batchImportRecordDo.getFileName();
            this.processedFile = batchImportRecordDo.getErrorFileUrl();
            this.lineCount = batchImportRecordDo.getLineCount();
            this.errorCount = batchImportRecordDo.getErrorCount();
            this.successCount = batchImportRecordDo.getSuccessCount();
            this.statusName = BatchImportStatusEnum.getNameByEnumName(batchImportRecordDo.getStatus());
            this.operationTime = DateUtil.format(batchImportRecordDo.getCreateTime(), "yyyy-MM-dd HH:mm:ss");
        }

    }

}
